package juc.base;

import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;

public class FutureTaskDemo {
    /*FutureTask get（）方法是阻塞的，
    只能按照程序顺序执行得到结果*/
    public static void main(String[] args) throws Exception {

        FutureTask futureTask = new FutureTask(() -> {
            TimeUnit.SECONDS.sleep(3);
            return "aaaa";
        });
        new Thread(futureTask).start();
        System.out.println(futureTask.get());
        System.out.println("end");
    }
}